package zdream.pmfield.doc.translator;

import java.util.Map;

import zdream.pmfield.data.foe.MoveType;
import zdream.pmfield.data.foe.Type;
import zdream.pmfield.data.foe.VStat;

import static zdream.pmfield.data.foe.MoveAdditionalEffects.*;

/**
 * @author Zdream
 * @date 2023-11-29
 * @since 0.0.1
 */
public class MoveTermTranslator {

	public static String typeName(Type type) {
		switch (type) {
		case STEEL: return "钢";
		case FIRE: return "火";
		case NORMAL: return "普通";
		case GRASS: return "草";
		case ELECTRIC: return "电";
		case OTHER: return "其它";
		case WATER: return "水";
		case ICE: return "冰";
		case DARK: return "暗";
		case MIND: return "精神";
		case SAND: return "砂";
		case WIND: return "风";
		case LIGHT: return "光";
		}
		return null;
	}

	public static String moveTypeName(MoveType type) {
		switch (type) {
		case MOVEMENT: return "行动";
		case STATUS: return "状态";
		case SPECIAL: return "特殊";
		case PHYSICAL: return "物理";
		}
		return null;
	}

	public static String vStatName(VStat vStat) {
		switch (vStat) {
		case FLEXIBILITY: return "灵活";
		case LUCK: return "幸运";
		case STRENGTH: return "力量";
		case TALENT: return "才能";
		case VITALITY: return "活力";
		case AWARENESS: return "意识";
		case INTELLIGENCE: return "智力";
		}
		return null;
	}

	public static String effectName(String effectText) {
		if (effectText == null) {
			return null;
		}

		final EffectDescription description = EffectDescription.of(effectText);

		switch (description.category) {
		case E_BURN: return "烧伤";
		case E_PARALYSIS: return "麻痹";
		case E_DELAY: return "推迟行动";
		}

		final Map<String, ?> values = parse(description);
		switch (description.category) {
		case E_FIXED: {
			StringBuilder builder = new StringBuilder();
			for (Map.Entry<String, ?> entry : values.entrySet()) {
				builder.append("对").append(typeName(Type.valueOf(entry.getKey()))).append("系");
				int value = (Integer) (entry.getValue());
				builder.append(value == 1 ? "效果拔群" : value == 0 ? "效果正常" : value == -1 ? "效果一般" : "无效果");
				builder.append("; ");
			}
			builder.delete(builder.length() - 2, builder.length());
			return builder.toString();
		}
		}

		return effectText;
	}
}
